package network.client;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class ChatWindow {
    public static void main(String[] args) {
        while (true) {
            try (ServerSocket ss = new ServerSocket(Integer.parseInt(args[0]));
                 Socket s = ss.accept();
                 BufferedReader br = new BufferedReader(new InputStreamReader(s.getInputStream()))
            ) {
                while (true) {
                    System.out.println(br.readLine());
                }
            } catch (IOException e) {
                Printer.print("Input has disconnected. Waiting on port " + args[0] + " for reconnect.");
            }
        }
    }
}
